/*
 * Copyright (c)  2015~2020, xforceplus
 * All rights reserved.
 * Project:datacare-orm
 * Id: IsBlank.java   2020-10-10 21-28-11
 * Author: Evan
 */
package cn.datacare.orm.engine.function;

import org.beetl.core.Context;
import org.beetl.core.Function;

/**
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: 2015~2020
 * </p>
 * <p>
 * Company/Department: xforceplus
 * </p>
 *
 * @author Evan
 * <b>Creation Time:</b> 2020-10-10 21-28-11
 * @since V1.0
 */
public class IsBlankFunction implements Function {
    @Override
    public Boolean call(Object[] paras, Context ctx) {
        Object o = paras[0];
        if (o == null) {
            return true;
        }
        if (!(o instanceof String)) {
            throw new IllegalArgumentException("期望参数是String");
        }
        String cs = (String) o;
        return cs.trim().length() == 0;

    }
}
